package com.xjc.business.controller.classadmin;

import com.xjc.business.entity.vo.classadmin.StuVo;
import com.xjc.business.service.StudentsService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 徐锦程
 * 时间:2025-01-31 9:52
 */
@RestController
@RequestMapping("/class_admin/student")
public class ClassStuController {

    @Autowired
    StudentsService studentsService;

    /**
     * 获取学生列表
     * @param classId 班级id
     * @return 列表
     */
    @GetMapping("/list/{classId}")
    public Result<List<StuVo>> getStuList(@PathVariable(value = "classId",required = false) Integer classId) {

        if (classId == null) {
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return studentsService.getStuList(classId);
    }
}